<?php
namespace app\service;

use think\facade\Db;

class AddressService
{
    public static function datalist($param=null)
    {
        $where=array();
        if(!empty($param['where']))
        {
            $where=$param['where'];
        }
        $order='id desc';
        if(!empty($param['order']))
        {
            $order=$param['order'];
        }
        $field='*';
        if(!empty($param['field']))
        {
            $field=$param['field'];
        }
        $datalist=Db::name('UserAddress')->where($where)->field($field)->order($order)->paginate(['list_rows'=>10,'query'=>$param['query']]);
        $data_list=array();
        foreach($datalist as $k=>$v)
        {
            $v['add_time']=formatdate($v['add_time']);
            $data_list[]=$v;
        }
        return ['datalist'=>$data_list,'total'=>$datalist->total(),'pager'=>$datalist->render()];
    }
}